package com.metacube.metaconnect.model;

import java.net.InetAddress;
import java.net.UnknownHostException;

public class GenerateActivationLink {

	/**
	 * generates activation link for user
	 * 
	 * @return activation link code generated for user
	 */
	public String generateActivationLink() {

		boolean checkResult;

		int activationCode = (int) (Math.random() * 1000000);

		checkResult = new UserInformationDAO().check(activationCode);

		if (checkResult) {
			generateActivationLink();
		}
		String activationLink = null;
		try {
			InetAddress ip = InetAddress.getLocalHost();
			activationLink = new String(
					ip.getHostAddress()
							+ ":8080/MetaConnect/ValidateActivationCodeServlet?activationCode="
							+ activationCode);
		} catch (UnknownHostException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		return activationLink;

	}

}
